*****************************************************************************
*																			*
*			This file reproduces tables 4, A5, A6							*
*																			*
*****************************************************************************

/* 
Replication Material for:
Maria Preißinger & Harald Schoen (2016): It's not always the campaign - 
Explaining inter-elction switching in Germany, 2009-2013. Electoral Studies.

Date: Sep 2016
*/


*--------------------------------------------------------------------------------
* Inter-election switch allgemein mit kategorisierten UV
*--------------------------------------------------------------------------------


estimates clear
eststo: logit wechsler b1.kat_b_skaloafd1 i.kat_changeskaloafdabs_17 ///
	i.kat_changekandcduabs_71 i.kat_changekandcduabs_17 ///
	i.kat_changekandspdabs_71 i.kat_changekandspdabs_17 ///
	kat_b_kern2 i.kat_changekernabs_25 ///
	kat_b_schuldhilfe3 i.kat_changeschuldhilfeabs_37	
margins, dydx(*) post
estimates store margins1

esttab margins1 using margins_finale_Modelle.rtf, ///
	b(2) se drop(0.kat_change* 1.kat_b*) label replace ///
	mtitle("Inter-election Switching") ///
	coeflabel(0.kat_b_skaloafd1 "start campaign AfD = negative" ///
	2.kat_b_skaloafd1 "start campaign AfD = positive") ///
	starlevels(# 0.10 * 0.05 ** 0.01 *** 0.001) ///
	title("Table 4: Prediction of Inter-Election Switching (undirected), marginal effects") ///
	note("Depicted are discrete changes in predicted probabilities for P(Switching=1), if someone changes his attitude.")
	
esttab est1 using logit_finale_Modelle.rtf, 	///
	b(2) se drop(0.kat_change* 1.kat_b*) label replace pr2 ///
	mtitle("Inter-election Switching") eqlabels(none) ///
	coeflabel(0.kat_b_skaloafd1 "start campaign AfD = negative" ///
	2.kat_b_skaloafd1 "start campaign AfD = positive") ///
	starlevels(# 0.10 * 0.05 ** 0.01 *** 0.001) ///
	title("Table A5: Prediction of Inter-Election Switching (undirected)") ///
	note("Depicted are b-coefficients and standrad errors (log odds).")


*-------------------------------------------------------------------
* Inter-Election Switch betsimmte Parteien mit kategorisierten UVS
*--------------------------------------------------------------------

estimates clear

eststo: logit tocdu b1.kat_b_skaloafd1 kat_changeskaloafddir_17 ///
	kat_changekandcdudir_71 kat_changekandcdudir_17 ///
	kat_changewslagedir_71 kat_changewslagedir_17 ///
	kat_b_kern2 kat_changekerndir_25 ///
	kat_b_schuldhilfe3 kat_changeschuldhilfedir_37
margins, dydx(*) post
estimate store margins2

eststo: logit tospd b1.kat_b_skaloafd1 kat_changeskaloafddir_17 ///
	kat_changekandspddir_71 kat_changekandspddir_17 ///
	kat_changewslagedir_71 kat_changewslagedir_17 ///
	kat_b_kern2 kat_changekerndir_25 ///
	kat_b_schuldhilfe3 kat_changeschuldhilfedir_37
margins, dydx(*) post
estimates store margins3	
	
esttab margins2 margins3 using margins_finale_Modelle.rtf, ///
	b(2) se drop(1.kat_b*) label append ///
	order(0.kat_b_skaloafd1 2.kat_b_skaloafd1 ///
	kat_changeskaloafddir_17 ///
	kat_changekandcdudir_71 kat_changekandcdudir_17 ///
	kat_changekandspddir_71 kat_changekandspddir_17 ///
	kat_changewslagedir_71 kat_changewslagedir_17 ///
	kat_b_kern2 kat_changekerndir_25 ///
	kat_b_schuldhilfe3 kat_changeschuldhilfedir_37) ///
	mtitle("Towards CDU/CSU" "Towards SPD") ///
	coeflabel(0.kat_b_skaloafd1 "start campaign AfD = negative" ///
	2.kat_b_skaloafd1 "start campaign AfD = positive") ///
	starlevels(# 0.10 * 0.05 ** 0.01 *** 0.001) ///
	title("Table 4: Prediction of Inter-Election Switching towards specific party, marginal effects")
	
esttab est1 est2 using logit_finale_Modelle.rtf, ///
	b(2) se drop(1.kat_b*) label append eqlabels(none) pr2 ///
	order(0.kat_b_skaloafd1 2.kat_b_skaloafd1 ///
	kat_changeskaloafddir_17 ///
	kat_changekandcdudir_71 kat_changekandcdudir_17 ///
	kat_changekandspddir_71 kat_changekandspddir_17 ///
	kat_changewslagedir_71 kat_changewslagedir_17 ///
	kat_b_kern2 kat_changekerndir_25 ///
	kat_b_schuldhilfe3 kat_changeschuldhilfedir_37) ///
	mtitle("Towards CDU/CSU" "Towards SPD") ///
	coeflabel(0.kat_b_skaloafd1 "start campaign AfD = negative" ///
	2.kat_b_skaloafd1 "start campaign AfD = positive") ///
	starlevels(# 0.10 * 0.05 ** 0.01 *** 0.001) ///
	title("Table A5: Prediction of Inter-Election Switching towards specific party")

	
*--------------------------------------------------------------------------
* Robustness check: entering independent variables as k-1 dummies
*---------------------------------------------------------------------------

* Undirected
logit wechsler b1.kat_b_skaloafd1 i.kat_changeskaloafdabs_17 ///
	i.kat_changekandspdabs_71 i.kat_changekandspdabs_17 ///
	i.kat_changekandcduabs_71 i.kat_changekandcduabs_17 ///
	b1.kat_b_kern2 i.kat_changekernabs_25 ///
	b1.kat_b_schuldhilfe3 i.kat_changeschuldhilfeabs_37	
margins b1.kat_b_skaloafd1 i.kat_changeskaloafdabs_17 ///
	i.kat_changekandspdabs_71 i.kat_changekandspdabs_17 ///
	i.kat_changekandcduabs_71 i.kat_changekandcduabs_17 ///
	b1.kat_b_kern2 i.kat_changekernabs_25 ///
	b1.kat_b_schuldhilfe3 i.kat_changeschuldhilfeabs_37, post
estimates store margins4	

esttab margins4 using margins_robustcheck.rtf, ///
	b(2) se label replace ///
	title("Table A6: Modelling inter-election switching with independent variables in dummy format") 
	
	
	
* CDU
logit tocdu b1.kat_b_skaloafd1 b1.kat_changeskaloafddir_17 ///
	b1.kat_changekandcdudir_71 b1.kat_changekandcdudir_17 ///
	b1.kat_changewslagedir_71 b1.kat_changewslagedir_17 ///
	b1.kat_b_kern2 b1.kat_changekerndir_25 ///
	b1.kat_b_schuldhilfe3 b1.kat_changeschuldhilfedir_37
margins b1.kat_b_skaloafd1 b1.kat_changeskaloafddir_17 ///
	b1.kat_changekandcdudir_71 b1.kat_changekandcdudir_17 ///
	b1.kat_changewslagedir_71 b1.kat_changewslagedir_17 ///
	b1.kat_b_kern2 b1.kat_changekerndir_25 ///
	b1.kat_b_schuldhilfe3 b1.kat_changeschuldhilfedir_37, post	
estimates store margins5	
	

* SPD
logit tospd b1.kat_b_skaloafd1 b1.kat_changeskaloafddir_17 ///
	b1.kat_changekandspddir_71 b1.kat_changekandspddir_17 ///
	b1.kat_changewslagedir_71 b1.kat_changewslagedir_17 ///
	b1.kat_b_kern2 b1.kat_changekerndir_25 ///
	b1.kat_b_schuldhilfe3 b1.kat_changeschuldhilfedir_37	
margins b1.kat_b_skaloafd1 b1.kat_changeskaloafddir_17 ///
	b1.kat_changekandspddir_71 b1.kat_changekandspddir_17 ///
	b1.kat_changewslagedir_71 b1.kat_changewslagedir_17 ///
	b1.kat_b_kern2 b1.kat_changekerndir_25 ///
	b1.kat_b_schuldhilfe3 b1.kat_changeschuldhilfedir_37, post		
estimates store margins6	

esttab margins5 margins6 using margins_robustcheck.rtf, ///
	b(2) se  append ///
	title("Table A7: Modelling inter-election switching with independent variables in dummy format") ///
	mtitle("CDU" "SPD")
